package com.fuershiye.woman.monitor.constants;

import com.fuershiye.woman.monitor.beans.IdName;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* 监测指标的类型 1：妇女 2：儿童 3：经济
* */
public enum MonitorType {

    women(1, "妇女"),
    children(2, "儿童"),
    economy(3, "经济"),

	;

    private final Integer id;
    private final String name;

    private static final Map<Integer,MonitorType> lookupById=new HashMap<Integer, MonitorType>();
    private static final List<IdName> allIdName = Lists.newArrayList();

    static {
        for(final MonitorType r: EnumSet.allOf(MonitorType.class)){
            lookupById.put(r.getId(), r);
        }
    }

    static {
    	for(final MonitorType r: EnumSet.allOf(MonitorType.class)){
    		allIdName.add(new IdName(r.getId(), r.getName()));
    	}
    }

    static {
    	for(final MonitorType r: EnumSet.allOf(MonitorType.class)){
            lookupById.put(r.getId(), r);
    	}
    }

    MonitorType(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    public Integer getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public static MonitorType getById(int id){
        return lookupById.get(id);
    }
    
    public static String getNameById(int id){
    	if(lookupById.containsKey(id)){
        	return lookupById.get(id).name;
    	}
    	return "";
    }
    
    public static Map<Integer,MonitorType> getAll(){
    	return lookupById;
    }
    
    public static List<IdName> getAllIdName(){
    	return allIdName;
    }

}
